home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 386 / insttest / andiswap.s < prev    next >
Text File  |  1985-11-19  |  2KB  |  75 lines

  1.  ; Program Name: ANDISWAP.S
  2.  ;      Version: 1.003
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    Assemble in PC-relative mode and save with a TOS extension.
  7.  
  8.  ; Program Function:
  9.  
  10.  ;    Compares the relative speed and memory requirements of
  11.  
  12.  ;                         andi.l #$00FF, dn
  13.  
  14.  ;    to                   swap, dn
  15.  ;                         clr.w dn
  16.  ;                         swap, dn
  17.  
  18.  ; in an effort to confirm or refute the assertion on page 201 of the
  19.  ; Kelly-Bootle book that the second algorithm is a faster.  The execution
  20.  ; time reported is for 50,000 executions of each algorithm.
  21.   
  22. calculate_program_size:
  23.  lea        -$102(pc), a1       ; Fetch basepage start address.
  24.  lea        program_end, a0     ; Fetch program end = array address.
  25.  trap       #6                  ; Return unused memory to op system.
  26.  lea        stack, a7
  27.  
  28. initialize_registers_1:
  29.  lea        header_1, a0       
  30.  lea        header_2, a1
  31.  lea        andi_start, a3
  32.  lea        andi_end, a4
  33.  lea        heading, a5
  34.  move.w     #50000, d7
  35.  trap       #9
  36.  
  37. initialize_registers_2:
  38.  lea        header_3, a0       
  39.  lea        header_4, a1
  40.  lea        swap_clr_start, a3
  41.  lea        swap_clr_end, a4
  42.  lea        heading, a5
  43.  move.b     #0, (a5)            ; Store a NULL in first byte to create a
  44.  move.w     #50000, d7          ; null string so that heading gets printed
  45.  trap       #9                  ; only once.
  46.  
  47. terminate:
  48.  trap       #8
  49.  
  50. andi_start:                
  51.  andi.l     #$00FF, d0
  52. andi_end:
  53.  
  54. swap_clr_start:        
  55.  swap       d0
  56.  clr.w      d0
  57.  swap       d0
  58. swap_clr_end:
  59.  
  60.  data
  61. heading:      dc.b       "ANDISWAP Program Results",$D,$A,$D,$A,0
  62. header_1:     dc.b       "  Elapsed time for andi.l #$00FF, dn: ",0
  63. header_2:     dc.b       "  Memory required for first algorithm:   ",0
  64. header_3:     dc.b $D,$A,"  Elapsed time for swap,  dn",$D,$A
  65.               dc.b       "                   clr.w  dn",$D,$A
  66.               dc.b       "                   swap   dn:         ",0
  67. header_4:     dc.b       "  Memory required for second algorithm:  ",0
  68.  bss
  69.  align
  70. label:        ds.l  1
  71.               ds.l 96
  72. stack:        ds.l  0
  73. program_end:  ds.l  0 
  74.  end